package com.wlz.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author wlz
 * @date 2022-06-27  9:30 下午
 */
public class RabbitUtils {

    private static ConnectionFactory connectionFactory = new ConnectionFactory();

    static {
        connectionFactory.setHost("106.52.11.147");
        connectionFactory.setPort(5672);//5672是RabbitMQ的默认端口号
        connectionFactory.setUsername("wlz");
        connectionFactory.setPassword("wlz@123456");
        connectionFactory.setVirtualHost("/wlz");
    }

    public static Connection getConnection() {
        Connection connection =null;
        try {
            connection = connectionFactory.newConnection();
            return connection;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
